package com.simplegovern.dict.dao;

import com.simpleframe.persistence.hibernate.Finder;
import com.simpleframe.persistence.hibernate.HibernateGenericDao;
import com.simpleframe.persistence.hibernate.OrderBy;
import com.simpleframe.persistence.hibernate.Page;
import com.simpleframe.persistence.hibernate.Searcher;
import com.simpleframe.persistence.hibernate.Searchers;
import com.simplegovern.dict.Dict;
import com.simplegovern.dict.DictItem;

public class DictItemDAO extends HibernateGenericDao<DictItem, Long>{
	
	public Page getPage(Searcher searcher,Dict dict){
		Finder finder = searcher.createFinder(DictItem.class);
		finder.andEq("typeId", dict.getId());
		finder.addOrder(OrderBy.desc("sort"));
		
		Searchers searchers = finder.createSearchers(searcher);
		searchers.andLike("name");
		
		return findPageByFinder(finder);
	}
}